﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Content;
using ShevaEngine.Core.Modules.Materials;
using ShevaEngine.Core.Modules.Models;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace ShevaEngine.Core.Modules.Renderer
{
    /// <summary>
    /// Draw call.
    /// </summary>
    public class DrawCall
    {
        /// <summary>The index buffer for this mesh part.</summary>
        [ContentSerializerIgnore]
        public IndexBuffer IndexBuffer;
        /// <summary>The vertex buffer for this mesh part.</summary>
        [ContentSerializerIgnore]
        public VertexBuffer VertexBuffer;
        /// <summary>Typ primitiva.</summary>
        public PrimitiveType PrimitiveType;
        /// <summary>The number of vertices used during a draw call.</summary>
        public int NumVertices;
        /// <summary>The number of primitives to render.</summary>
        public int PrimitiveCount;
        /// <summary>The location in the index array at which to start reading vertices.</summary>
        public int StartIndex;
        /// <summary>The offset (in vertices) from the top of vertex buffer.</summary>
        public int VertexOffset;
        /// <summary>Base vertex.</summary>
        public int BaseVertex;                

        /// <summary>
        /// Konstruktor.
        /// </summary>
        public DrawCall()
        {
        }

        /// <summary>
        /// Metoda vykresli objekt
        /// </summary>
        public void Render()
        {
            //ShevaEngine.Instance.GraphicsDevice.SetVertexBuffer(this.VertexBuffer);
            //ShevaEngine.Instance.GraphicsDevice.Indices = this.IndexBuffer;

            ShevaEngine.Instance.GraphicsDevice.DrawIndexedPrimitives(
                this.PrimitiveType, this.BaseVertex, 0, this.NumVertices, this.StartIndex, this.PrimitiveCount);
        }
    }
}
